//---------------------------------------------------------------------------
#include <windows.h>
#include<stdio.h>
#include<conio.h>
#include "resource.h"
#pragma hdrstop

//---------------------------------------------------------------------------

#pragma argsused
//---------------------------------------------------------------------------
LPCTSTR ClsName = L"FundApp";
LPCTSTR WndName = L"Project";
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT uMsg,
			      WPARAM wParam, LPARAM lParam);
//---------------------------------------------------------------------------
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine, int nCmdShow)
{
	MSG        Msg;
	HWND       hWnd;
	WNDCLASSEX WndClsEx;

	// Create the application window
	WndClsEx.cbSize        = sizeof(WNDCLASSEX);
	WndClsEx.style         = CS_HREDRAW | CS_VREDRAW;
	WndClsEx.lpfnWndProc   = WndProcedure;
	WndClsEx.cbClsExtra    = 0;
	WndClsEx.cbWndExtra    = 0;
	WndClsEx.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
	WndClsEx.hCursor       = LoadCursor(NULL, IDC_ARROW);
	WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	WndClsEx.lpszMenuName  = MAKEINTRESOURCE(IDR_MENU1);
	WndClsEx.lpszClassName = ClsName;
	WndClsEx.hInstance     = hInstance;
	WndClsEx.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

	// Register the application
	RegisterClassEx(&WndClsEx);

	// Create the window object
	hWnd = CreateWindowEx(0,
                          ClsName,
                          WndName,
               			  WS_OVERLAPPEDWINDOW,
                          CW_USEDEFAULT,
               			  CW_USEDEFAULT,
                          CW_USEDEFAULT,
               			  CW_USEDEFAULT,
                          NULL,
                          NULL,
                          hInstance,
                          NULL);
	
	// Find out if the window was created
	if( !hWnd ) // If the window was not created,
		return FALSE; // stop the application

	// Display the window to the user
	ShowWindow(hWnd, nCmdShow);// SW_SHOWNORMAL);
	UpdateWindow(hWnd);

	// Decode and treat the messages
	// as long as the application is running
	while( GetMessage(&Msg, NULL, 0, 0) )
	{
             TranslateMessage(&Msg);
             DispatchMessage(&Msg);
	}

	return Msg.wParam;
}
BOOL CALLBACK AboutDlgProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
        case WM_INITDIALOG:

        return TRUE;
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case IDOK:
                    EndDialog(hWnd, IDOK);
                break;
                case IDCANCEL:
                    EndDialog(hWnd, IDCANCEL);
                break;
            }
        break;
        default:
            return FALSE;
    }
    return TRUE;
}
//---------------------------------------------------------------------------
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg,
			   WPARAM wParam, LPARAM lParam)
{
    switch(Msg)
    {
    case WM_DESTROY:
        PostQuitMessage(WM_QUIT);
        break;
	case WM_CREATE:
		MessageBox(NULL,L"Proiect realizat de Marin Bogdan",L"APPLICATION", NULL);
	break;
		 case WM_COMMAND:
            switch(LOWORD(wParam))
            {
				case ID_FILE_NEWW:
					{
					 int ret = DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG1), hWnd, AboutDlgProc);
					if(ret == IDOK)
					 {}
				 else if(ret == -1){
				    MessageBox(hWnd, L"Dialog failed!", L"Error",MB_OK | MB_ICONINFORMATION);
				 }
					 case ID_FILE_EXIT:
				{
					MessageBox(NULL,L"VA MULTUMESC!!!",L"EXIT APPLICATION", NULL);
					DestroyWindow(hWnd);
					break;
				}
				case ID_HELP_GO:
					{
						MessageBox(NULL,L"GO TO HELP",L"HELP APPLICATION", NULL);
						break;
					}

            }
        break;
            }
    default:
        // Process the left-over messages
        return DefWindowProc(hWnd, Msg, wParam, lParam);
    }
    // If something was not done, let it go
    return 0;
}
//---------------------------------------------------------------------------